package com.yang.Inet.test;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerSockerDemo {

	public static void main(String[] args) throws IOException {
		ServerSocket ss = new ServerSocket(10001);
		// 获取客户端
		Socket s = ss.accept();
		// 客户端 信息
		String name = s.getInetAddress().getHostName();

		InputStream input = s.getInputStream();

		byte[] buf = new byte[1024];
		int read = input.read(buf);
		String text = new String(buf, 0, read);
		
		System.out.println(name + "  " + text );
		
		OutputStream out = s.getOutputStream();
		out.write("我收到了".getBytes());
		
		ss.close();

	}

}
